package com.sky.mapper;

import com.sky.anno.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    //根据分类id查询菜品数量
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    //新增菜品
    @AutoFill(value = OperationType.INSERT)
    void add(Dish dish);
    //菜品分页查询
    List<Dish> findByPage(DishPageQueryDTO dishPageQueryDTO);

//    根据菜品id查询起售中的菜品数量
    @Select("select * from dish where status = 1 and id = #{id}")
    Dish findByStatusAndId(Long id);
    // 删除菜品基本信息
    void deleteByIds(List<Long> ids);

    //根据id查询菜品
    DishDTO findById(Long id);

//    修改菜品
@AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    //根据分类id查询菜品
    List<Dish> list(Long categoryId);
}
